package edu.jd.movieplatform.user.long_comment.impl;

import edu.jd.movieplatform.user.long_comment.LongComment;
import edu.jd.movieplatform.user.long_comment.LongCommentDto;
import edu.jd.movieplatform.user.long_comment.LongCommentService;
import edu.jd.movieplatform.user.long_comment.dao.LongCommentDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * @descriptions:
 * @data: 2021/7/9 22:06
 */
@Service  @Transactional
public class LongServiceImpl implements LongCommentService {
    @Resource
    private LongCommentDao dao;

    @Override
    public List<LongComment> GetLongCommentList(Integer mov_id) {

        return dao.getLongCommentList(mov_id);
    }

    @Override
    public boolean CreateLongComment(LongCommentDto dto) {
        Integer NewNum = dao.findLongCommentNewNum();
        dto.setLong_com_id(NewNum);

        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        dto.setCom_time(df.format(new Date()));// new Date()为获取当前系统时间

        return dao.createLongCommentDto(dto);
    }
}
